import { handleCommonRes } from '@gis/lib/utils/resolver.js';
import { BasicMarker } from '../../js/BasicMarker.js';
import { BasicMarkers } from '../../js/BasicMarkers.js';
import { getMarkerIcon } from '../../js/icon.js';
import { useUserInfoStore } from '@gis/lib/pinia/userInfo.js';
import { getAddressList } from '@gis/lib/api';

/*
 * 核酸点位
 * */

class Marker extends BasicMarker {
  constructor({ map, data }) {
    super({ map, data });
    /* this.type: 这个type主要用于筛选,需要和filter-legend里面的type相对应 */
    this.type = 'hesuandw';
    super.create();
  }
  getIcon() {
    return getMarkerIcon(this.type);
  }
  getLabelContent() {
    return `<div class="marker_label">
              <p class="marker_label__name">${this.data.name}</p>
<!--              <p class="marker_label__count">${this.data.address}</p>-->
            </div>`;
  }

  onClick() {
    // dialog( {
    //   content: () => import("@/views/homestay-warning/components/point-detail"),
    //   contentProps: {
    //     yard_id: this.data.yard_id,
    //   },
    //   dialogProps: {
    //     title: `预警列表`,
    //     bodyStyle: {
    //       width: "1200px",
    //       height: "69vh",
    //     },
    //   },
    // });
  }
}

export default class Hesuandw extends BasicMarkers {
  constructor({ map }) {
    super();
    this.map = map;
  }
  createMarker(data) {
    return new Marker({ map: this.map, data });
  }
  async getDataAsync() {
    const { area_code } = useUserInfoStore();
    const params = {
      area_code: area_code,
      type_code: "'6_16'",
    };
    const data = await handleCommonRes(getAddressList, params);
    return data.map((item) => Object.assign(item, { lnglat: [item.longitude, item.latitude] }));
  }
}
